package ramosmanuales.data.xml;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import ramosmanuales.util.Quincena;

@XmlRootElement(name = "ordenDescuento")
@XmlType(propOrder = {"noPrestamo", "plazo", "anioIni", "qnaIni", "anioFin",
                      "qnaFin", "monto", "descuento"})
public class OrdenDescuento {
    private String noPrestamo;
    private String plazo;
    private String anioIni;
    private String qnaIni;
    private String anioFin;
    private String qnaFin;
    private String monto;
    private String descuento;

    @XmlElement(name = "noPrestamo")
    public String getNoPrestamo(){
        return noPrestamo;
    }

    public void setNoPrestamo(String noPrestamo){
        this.noPrestamo = noPrestamo;
    }

    @XmlElement(name = "plazo")
    public String getPlazo(){
        return plazo;
    }

    public void setPlazo(String plazo){
        this.plazo = plazo;
    }

    @XmlElement(name = "anioIni")
    public String getAnioIni(){
        return anioIni;
    }

    public void setAnioIni(String anioInicial){
        this.anioIni = anioInicial;
    }

    @XmlElement(name = "qnaIni")
    public String getQnaIni(){
        return qnaIni;
    }

    public void setQnaIni(String quincenaInicial){
        this.qnaIni = quincenaInicial;
    }

    @XmlElement(name = "anioFin")
    public String getAnioFin(){
        return anioFin;
    }

    public void setAnioFin(String anioFinal){
        this.anioFin = anioFinal;
    }

    @XmlElement(name = "qnaFin")
    public String getQnaFin(){
        return qnaFin;
    }

    public void setQnaFin(String quincenaFinal){
        this.qnaFin = quincenaFinal;
    }

    @XmlElement(name = "monto")
    public String getMonto(){
        return monto;
    }

    public void setMonto(String monto){
        this.monto = monto;
    }

    @XmlElement(name = "descuento")
    public String getDescuento(){
        return descuento;
    }

    public void setDescuento(String descuento){
        this.descuento = descuento;
    }

    public Quincena getRangoIni(){
        if(anioIni!=null&&qnaIni!=null)
            return new Quincena(Integer.parseInt(anioIni), Integer.parseInt(qnaIni));
        else
            return new Quincena();
    }

    public Quincena getRangoFin(){
        if(anioFin!=null&&qnaFin!=null)
            return new Quincena(Integer.parseInt(anioFin), Integer.parseInt(qnaFin));
        else
            return new Quincena();
    }

    public Object[] getElements(){
        return new Object[] {noPrestamo, plazo, anioIni, qnaIni, anioFin,
                             qnaFin, monto, descuento};
    }
}
